﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KaoWuYouLibs.Dal;
using KaoWuYouLibs.Model;

namespace KaoWuYouLibs.Bll
{
    public class GetListsBusiness
    {
        SubjectAccess subjectAccess = new SubjectAccess();
        SubclassAccess subclassAccess = new SubclassAccess();

        public List<SubjectModel> GetSubjectsAndInitSubclasses()
        {
            try
            {
                List<SubjectModel> re = new List<SubjectModel>();
                re = subjectAccess.FindAllSubjects();

                foreach (var subject in re)
                {
                    subject.Subclasses = subclassAccess.GetOwnedSubclasses(subject.SubjectID);
                }
                return re;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}
